home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 September / Macworld (1998-09).dmg / Shareware World / Info / For Developers / Chipmunk_Basic_3.5.5 / basic.man next >
Text File  |  1998-06-13  |  30KB  |  1,099 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE>Chipmunk Basic Man Page</TITLE>
  4. <H1>Chipmunk Basic Man Page</H1>
  5. </HEAD>
  6. <BODY>
  7. <HR>
  8. <PRE>
  9.  
  10.     BASIC(1)        chipmunk-basic v3.5.4             BASIC(1)
  11.  
  12.  
  13.     Chipmunk BASIC - 'BASIC' language interpreter
  14.     
  15.  
  16.     SYNOPSIS    ( UNIX )
  17.  
  18.     basic [ filename ]
  19.  
  20.     DESCRIPTION
  21.  
  22.     Chipmunk basic is an interpreter for the BASIC language. If
  23.     a filename parameter is given, then the named program file
  24.     is loaded into memory and run.  
  25.  
  26.     Basic commands and statements can be entered and interpreted
  27.     in immediate mode or executed as program statements when the
  28.     Basic program is run.  A built-in line number based editor
  29.     allows program input from the console keyboard.  See below
  30.     for the commands and statements that the interpreter
  31.     recognizes.
  32.     
  33.     FLAGS
  34.  
  35.     none
  36.  
  37.     COMMANDS
  38.         
  39.     Standard mumbleSoft-like Basic Commands:
  40.  
  41.     load STRINGEXPR
  42.  
  43.         Load a program into memory from the named file. The
  44.         program previously in memory is erased.  All files are
  45.         closed and all variables are cleared.  Lines beginning
  46.         with the '#' character will be treated as comments. 
  47.         All other lines in the file must begin with a line
  48.         number.  Duplicate line numbers are not allowed.
  49.  
  50.  
  51.     save STRINGEXPR
  52.  
  53.         Save the current program to the named file.
  54.  
  55.     new
  56.  
  57.         Erase the program in memory.  All files are closed and
  58.         all variables are cleared.
  59.  
  60.     clear
  61.  
  62.         All  variables are cleared.  All arrays and string
  63.         variables are deallocated.
  64.  
  65.     run { LINENUM }
  66.     run { STRINGEXPR { , LINENUM } }
  67.  
  68.         Begin execution of the program at the first line, or at
  69.         the specified line.  All variables are cleared.  If a
  70.         STRINGEXPR is given then the BASIC program with that
  71.         name file is loaded into memory first.  Program lines
  72.         are executed in line number order.
  73.  
  74.     cont
  75.  
  76.         CONTinue execution of the program on the next statement
  77.         after the statement on which the program stopped
  78.         execution due to a STOP command or an error.  See BUGS
  79.         section.
  80.  
  81.     LINENUM { TEXT }
  82.     
  83.         Enters a program line.  If a program line with
  84.         line number LINENUM exists, then it is replaced.
  85.         If no TEXT is given, the the program line with
  86.         line number LINENUM is deleted.
  87.     
  88.     list
  89.         List the whole program.
  90.         Line numbers above 999999999 will not list.
  91.  
  92.     list 1-3
  93.         List lines 1 to 2
  94.  
  95.     list -2
  96.         List lines up to 1
  97.  
  98.     list 1
  99.         List line 1
  100.     
  101.     list 2-
  102.         List lines from 2 on
  103.  
  104.     merge STRINGEXPR
  105.  
  106.         Loads a program into memory.  The previous program
  107.         remains in memory; variables are not cleared.  If a
  108.         line exists in both programs, the new merged line
  109.         overwrites the old one.
  110.  
  111.     renum STRINGEXPR VAL { , VAL { , VAL { , VAL} } }
  112.  
  113.         Renumber program lines.  By default, the new sequence is
  114.         10,20,30,... The first argument is a new initial line
  115.         number; the second argument is the increment between
  116.         line numbers. The third and fourth arguments, if
  117.         present, specify a limiting range of old line numbers
  118.         to renumber.  RENUM can be used to move non-overlapping
  119.         blocks of code.
  120.      
  121.     edit LINENUM
  122.  
  123.         Edit a single line. If the exit from the edit is via a
  124.         cntrl-c then do not change the line.
  125.             i    insert till <return>
  126.             x    delete one char
  127.             A    append to end of line
  128.  
  129.     del LINENUM [ - LINENUM ]
  130.  
  131.         Delete a line or specified range of lines. If not found
  132.         then no lines will be deleted.
  133.  
  134.     exit
  135.     bye
  136.     quit
  137.  
  138.         Terminates the basic interpreter, ending program
  139.         execution and closing all files.
  140.  
  141.  
  142.     STATEMENTS
  143.  
  144.     { let } VAR = EXPR
  145.  
  146.         Assign a value to a variable.  Variable names can be up
  147.         to 31 significant characters, consisting of letters,
  148.         digits, underscores, and an ending dollar sign.
  149.         Variable names are case insensitive.  Variables can
  150.         hold real numbers (IEEE double) or strings of up to 254
  151.         characters.  If the variable name ends with a "$" it
  152.         holds strings, otherwise it holds numbers.  If a
  153.         statement starts with a variable name then an implied
  154.         LET is assumed.
  155.  
  156.     print  VAL | STRINGVAL { [ , | ; ] VAL ... } { ; }
  157.     ?      VAL | STRINGVAL { [ , | ; ] VAL ... } { ; }
  158.     print # FNUM, VAL ...
  159.  
  160.         This command will print its parameters tab delimited.
  161.         If a semi-colon is used between parameters then no tab
  162.         is inserted between the parameters.  The print
  163.         output is terminated with a carriage return unless the
  164.         parameter list ends with a semi-colon.  If a file
  165.         descriptor is given then output is redirected to the
  166.         given file.  If a
  167.         
  168.             tab(VAL);
  169.             
  170.         is found in a print statement, then print output will
  171.         skip to the horizontal position specified by VAL.
  172.  
  173.     print { # FNUM, } using STRINGVAL ; VAR { [ , | ; ] VAR ... }
  174.     
  175.         Prints formatted numbers.  Legal characters for the
  176.         format string STRINGVAL are: + * $ # . E+ and trailing
  177.         spaces.
  178.         
  179.         Examples:
  180.         
  181.             print using "**$###.##"; 1.23  :' ****$1.23
  182.             print using "###.##"; 2.12345  :'   2.12
  183.             print using "#.##E+##"; 2345.6 :'   2.35E+03
  184.             
  185.     input  STRINGVAR | VAR  { , VAR }
  186.     input  "prompt"; { STRINGVAR | VAR  { , VAR } }
  187.     input  { # FNUM , } { STRINGVAR | VAR { , VAR } }
  188.  
  189.         Input from the console or from the file specified by
  190.         FNUM. If the input is from the console then a prompt
  191.         string can optionally be printed.
  192.         
  193.         *** NOTE ***
  194.         
  195.         All input to string variables is "line input"; a whole
  196.         input line will be read into one string variable.  The
  197.         number of comma seperated numeric values in the input
  198.         data must be less than or equal to the number of
  199.         numeric variables in the INPUT statement.  This INPUT
  200.         usage is different from other versions Basic.
  201.  
  202.     get STRINGVAR
  203.     
  204.         Gets one character from the console keyboard.  Blocking.
  205.     
  206.     fputbyte VAL, # FNUM
  207.     
  208.         Writes one byte to the file specified by FNUM.
  209.     
  210.     get # FNUM, VAL, TYPED-VAR
  211.     
  212.         Reads one record from a random access file into VAR.
  213.     
  214.     put # FNUM, VAL, TYPED-VAR
  215.     
  216.         Write one record to a random access file from VAR.
  217.     
  218.     cls
  219.         Clear the terminals screen.  Leaves the cursor in the
  220.         upper left corner.  For Applesoft BASIC fans, the
  221.         "home" command will also do this.
  222.  
  223.     end
  224.  
  225.         Terminates program execution and returns to the command
  226.         prompt.  Not required.
  227.  
  228.     stop
  229.  
  230.         Stops the execution of the program and returns to
  231.         the command prompt.  Prints a "Break..." message.
  232.  
  233.     if EXPR then STATEMENT { : STATEMENT } { : else STATEMENT }
  234.     if EXPR then LINENUM
  235.     if EXPR
  236.  
  237.         The IF statement.  If the condition is true then the
  238.         STATEMENTS after the THEN are executed and the
  239.         statements after the ELSE are skipped.  If the
  240.         condition is false then the statements after the "else"
  241.         are executed instead.  If the item after "then" is a
  242.         line number then a goto is executed.
  243.         
  244.         If the condition is true and there is no THEN on the
  245.         same line, statements are executed until a line
  246.         with an ENDIF is found.  (block IF() ... ENDIF)
  247.  
  248.     for VAR = EXPR to EXPR { step EXPR }
  249.  
  250.         Beginning of a FOR-NEXT loop.  It takes a starting
  251.         value, a limit and an optional step argument.  If the
  252.         step value is negative, the variable counts down.  The
  253.         body of the loop is not executed if the end condition
  254.         is true initially.
  255.  
  256.         Example:
  257.             for i=1 to 10 : print i, : next i
  258.             rem prints the numbers from 1 through 10
  259.  
  260.     next { VAR }
  261.  
  262.         End of a FOR-NEXT loop.  If the termination conditions
  263.         are met then execution falls through to the following
  264.         statement, otherwise execution returns to the statement
  265.         following the FOR statement with the corresponding
  266.         index variable. If there no index variable parameter,
  267.         the innermost FOR loop is used.
  268.  
  269.     exit for
  270.  
  271.         Exits the current FOR-NEXT loop.
  272.         
  273.     while { EXPR }
  274.  
  275.         Start of a WHILE loop. The loop is repeated until EXPR
  276.         is false. If EXPR is false at loop entry, then the loop
  277.         is not executed . A WHILE loop must be terminated by a
  278.         balancing WEND statement.
  279.  
  280.     wend { EXPR }
  281.  
  282.         Terminating statement of a WHILE loop.  If EXPR is true
  283.         then exit the loop.  Only one WEND is allowed for each
  284.         WHILE.  A WHILE-WEND loop without a condition will loop
  285.         forever.
  286.  
  287.     exit while
  288.  
  289.         Exits the current WHILE-WEND loop.
  290.         
  291.     gosub LINENUM
  292.  
  293.         Transfer command to a line number. Save return address
  294.         so that the program can resume execution at the
  295.         statement after the "gosub" command.  The recursion
  296.         depth is limited only by available memory.
  297.  
  298.     return
  299.  
  300.         Returns from the most recently activated subroutine
  301.         call (which must have been called by GOSUB).
  302.  
  303.     goto LINENUM
  304.  
  305.         This statement will transfer control to the line number
  306.         specified.  If the program is not running, then this
  307.         command will begin execution at the specified line
  308.         without clearing the variables.  An "Undefined line"
  309.         error will occur if LINENUM doesn't exist in the
  310.         program.
  311.  
  312.     on EXPR   goto  LINENUM { , LINENUM ... }
  313.     on EXPR   gosub LINENUM { , LINENUM ... }
  314.         This command will execute either a goto or a gosub to
  315.         the specified line number indexed by the value of EXPR.
  316.         If EXPR is larger than the number of LINENUMs, then
  317.         control passes to the next statement.
  318.         
  319.     on error  goto  LINENUM
  320.  
  321.         If the error form is used, only one linenumber is
  322.         allowed.  LINENUM is the line to which control is
  323.         transferred if an error occurs.  A GOTO or CONT
  324.         statement can be used to resume execution.  An error
  325.         inside a named SUB subroutine cannot be resumed from
  326.         or CONTinued.
  327.  
  328.     sub NAME ( VAR { , VAR ... } }
  329.  
  330.         Subroutine entry.  May be called by a CALL statement or
  331.         by NAME. A SUB subroutine must be exited by a RETURN or
  332.         END SUB statement.  There should be only one RETURN or
  333.         END SUB statement per SUB definition.  The variables in
  334.         the VAR list become local variables. String and numeric
  335.         arguments are passed by value; array arguments must be
  336.         pre-dimensioned and are passed by reference.
  337.         
  338.         Example:
  339.             110  x = foo (7, j)  : rem Pass 7 and j by value.
  340.             ...
  341.             2000 sub foo (x,y,z) : rem z is a local variable
  342.             2010   print x       : rem prints 7
  343.             ...
  344.             2080   foo = y+1     : rem return value
  345.             2090 end sub
  346.         
  347.         Subroutine definitions may not be nested.
  348.  
  349.  
  350.     select case EXPR
  351.     
  352.         Multi-way branch.  Executes the statements after
  353.         the CASE statement which matches the SELECT CASE
  354.         expression, then skips to the END SELECT statement.
  355.         If there is no match, and a CASE ELSE statement is
  356.         present, then execution defaults to the statements
  357.         following the CASE ELSE.
  358.         
  359.         Example:
  360.             200 select case x
  361.             210   case 2
  362.             ...
  363.             230   case 3, 4
  364.             ...
  365.             270   case else
  366.             ...
  367.             290 end select
  368.  
  369.  
  370.     dim VAR( d { , d { , d } } ) { , VAR( d { , d { , d } } ) }
  371.  
  372.         Dimension an array or list of arrays (string or numeric). 
  373.         A maximum of 4 dimensions can be used. The maximum
  374.         dimension size is limited by available memory. Legal
  375.         array subscripts are from 0 up and including the
  376.         dimension specified; d+1 elements are allocated.  All
  377.         arrays must be dimensioned before use.
  378.         
  379.         Example:
  380.             10 dim a(10)
  381.             20 for i=0 to 10
  382.             30   a(i) = i^2
  383.             40 next i
  384.             50 print a(5) : rem should print 25
  385.  
  386.     data ITEM { , ITEM }
  387.  
  388.         DATA statements contain the data used in the READ
  389.         statements. Items must be separated by commas.  The
  390.         items may be either numeric or string expressions,
  391.         corresponding to the type of variable being read.
  392.         Reading the wrong kind of object produces a "Type
  393.         mismatch" error.  Strings must be encapsulated with
  394.         quote marks.
  395.  
  396.     read VAR { , VAR }
  397.  
  398.         Read data from the DATA statements contained in the
  399.         program. List items can be either string or numeric
  400.         variables. Reading past the end the last DATA statement
  401.         generates an error.
  402.  
  403.     restore { LINENUM }
  404.  
  405.         The RESTORE statement causes the next READ to use the
  406.         first DATA statement in the program.  If a LINENUM is
  407.         given then the DATA statement on or after that
  408.         particular line is used next.
  409.  
  410.     rem or "`"
  411.  
  412.         A remark or comment statement.  Ignored by the program
  413.         during execution, however a REM statement can be the
  414.         target of a GOTO or GOSUB.
  415.  
  416.     open STRINGEXPR for { input|output|append } as # FNUM
  417.  
  418.         Open a file. The { input|output|append } parameter
  419.         specifies whether the file is to be read, written or
  420.         appended.  If STRINGEXPR is "stdin" for input or
  421.         "stdout" for output then the console will be used
  422.         instead of a file.  A "file not found" error will
  423.         occur if a non-existant file is specified in an OPEN
  424.         for input statement.  FNUM must be an integer value
  425.         between 0 and 8.
  426.  
  427.     open STRINGEXPR for random as # FNUM len = VAL
  428.  
  429.         Opens a random access file.  Only GET and PUT statement
  430.         are allowed to read and write random access files.
  431.  
  432.     open ... else goto LINENUM
  433.  
  434.         See OPEN command.
  435.         LINENUM is the line to which control is transferred if
  436.         an error in opening a file occurs.  The variable ERL is
  437.         set to the line number on which the file open error
  438.         occured.
  439.  
  440.     close # FNUM
  441.  
  442.         Close a file. Releases the file descriptor and flushes
  443.         out all stored data.
  444.  
  445.     def fnNAME ( VAR { , VAR } ) = EXPR
  446.  
  447.         Define a user definable function.  Obsolete.
  448.         
  449.         Example:
  450.             10 def fnplus(x,y) = x+y
  451.             20 print fnplus(3,5) : rem prints 8
  452.  
  453.     mat ARRAY-VAR = EXPR
  454.     
  455.         Fills a 1 or 2 dimensional array with a constant
  456.         value given by EXPR.
  457.  
  458.     mat ARRAY-VAR = ARRAY-VAR
  459.     
  460.         Copys a 2 dimensional array.  The dimensions
  461.         must match.
  462.  
  463.     mat ARRAY-VAR = transpose ARRAY-VAR
  464.     
  465.         Transposes a 2 dimensional array.  The dimensions of
  466.         the first array must correspond to the transpose of
  467.         the dimensions of the second array.
  468.  
  469.     mat ARRAY-VAR = ARRAY-VAR { + | * } { EXPR | ARRAY-VAR }
  470.     
  471.         Adds or multiplies a 2 dimensional array by either
  472.         an expression or another array.  The dimensions must
  473.         be appropriate for matrix addition or matrix
  474.         multiplication.
  475.  
  476.     mat origin { 0 | 1 }
  477.     
  478.         Sets the matrix index origin to either 0 or 1 for all
  479.         MAT statements, including fill.  Defaults to 0.
  480.  
  481.     type CLASSNAME
  482.     
  483.         Creates a structure definition type.  Each field
  484.         requires a separate line.  Legal types are string,
  485.         integer, longint and double.  The definition must
  486.         conclude with an END TYPE statement.  Use the
  487.         DIM AS NEW statement to create records containing
  488.         the structure specified by a TYPE statement.
  489.         
  490.         Example:
  491.             300 type person
  492.             310   name as string * 32 : rem = 31 chars length
  493.             320   age as integer      : rem  2 byte integers
  494.             330   weight as double      : rem  8 byte doubles
  495.             340 end type
  496.             400 dim friend1 as new person
  497.             410 friend1.name = "Mark" : friend1.age = 13
  498.             420 print friend1.name, friend1.age
  499.  
  500.  
  501.     class CLASSNAME { extends SUPERCLASSNAME }
  502.     
  503.         Creates a class definition.  Class definitions can then
  504.         be used to create objects with member functions (also
  505.         called methods.)  Classes inherit members from
  506.         superclasses (single inheritance.)
  507.         
  508.         Example:
  509.         CLASS bar
  510.           y AS integer
  511.           z AS PRIVATE double    ' private data
  512.           s AS PUBLIC string    ' public keyword optional
  513.           SUB blah(v)        ' public member function
  514.             this.y = v + 7
  515.           END SUB
  516.         END CLASS
  517.         
  518.         DIM b AS NEW bar    ' create object b
  519.         CALL b.blah(1)        ' send message "blah(1)" to b
  520.         
  521.         CLASS and TYPE definitions are global, and cannot be
  522.         nested inside other class definitions or subroutines.
  523.         
  524.     dim VAR { ( INT ) } as new CLASSNAME
  525.  
  526.         Create a record (TYPED-VAR) or object using a
  527.         previously defined structure definition type created
  528.         by TYPE...END TYPE or CLASS..END CLASS.  Optionally
  529.         creates an array of records or objects.
  530.         
  531.     erase VAR
  532.     
  533.         Un-dimensions a dimensioned array.  Frees memory.
  534.  
  535.     { let } mid$( STRINGVAR, EXPR1, EXPR2 ) = STRINGEXPR
  536.  
  537.         Replace the sub-string in STRINGVAR, starting at
  538.         character position EXPR1, with character length EXPR2,
  539.         with the (EXPR2 in length) string STRINGEXPR.
  540.  
  541.     { let } field$( STRINGVAR, VAL { ,STRINGVAL } ) = STRINGEXPR
  542.  
  543.         Replace the N-th field of STRINGVAR with STRINGEXPR.
  544.  
  545.     poke ADDR_EXPR, DATA_EXPR
  546.  
  547.         Poke a byte into a memory location. Unreasonable
  548.         addresses can cause bus or segmentation errors.
  549.  
  550.     push VAR { , VAR ... }
  551.  
  552.         Pushes one or more expressions or variables onto an
  553.         internal stack.  Expressions can be returned using the
  554.         POP function; variables can be returned by using the
  555.         POP statement.
  556.     
  557.     pop VAL
  558.  
  559.         POP statement (see also POP function). Pops VAL
  560.         variables off the internal stack, restoring the value
  561.         of those variables to their pushed values.
  562.     
  563.     exec(STRINGEXPR)
  564.  
  565.         Executes STRINGEXPR as a statement or command. 
  566.         e.g. exec("print " + "x") will print the value of x.
  567.  
  568.  
  569.     NUMERIC FUNCTIONS
  570.  
  571.     sgn(VAL)
  572.  
  573.         Returns the sign of the parameter value.  Returns 1 if
  574.         the value is greater than zero , zero if equal to zero.
  575.         -1 if negative.
  576.  
  577.     abs(x)
  578.  
  579.         Returns the absolute value of x.
  580.  
  581.     int(x)
  582.  
  583.         Returns the integer value of x.  Truncates toward zero.
  584.         The absolute value of x must be less than 2^31-1.
  585.  
  586.     floor(x)
  587.  
  588.         Returns the integer value of x.
  589.         Truncates toward negative infinity.
  590.  
  591.     sqr(x)
  592.  
  593.         Returns the square root of x.
  594.  
  595.     log(x)
  596.  
  597.         Returns the natural logarithm of x.
  598.  
  599.     log10(x)
  600.  
  601.         Returns the logarithm base 10 of x.
  602.  
  603.     exp(x)
  604.  
  605.         Returns e^x. e=2.7182818...
  606.  
  607.     sin(x)
  608.     cos(x)
  609.     atn(x)
  610.  
  611.         Trigonometric functions: sin, cosine and arctangent. 
  612.  
  613.     pi
  614.     
  615.         Returns pi, 3.141592653589793... 
  616.  
  617.     rnd ( EXPR )
  618.  
  619.         Returns an integer pseudo-random number between 0 and
  620.         int(EXPR)-1 inclusive. If EXPR is 1, then returns a
  621.         rational number between 0 (inclusive) and 1.  If EXPR
  622.         is negative then EXPR seeds the random number generator.
  623.  
  624.     randomize EXPR
  625.  
  626.         Seeds the random number generator with the integer
  627.         EXPR. The pseudo-random number generator should return
  628.         the same sequence when seeded with the same start
  629.         value.  The actual sequence may be system dependant.
  630.  
  631.     len( STRINGEXPR )
  632.  
  633.         Returns the length of the string STRINGEXPR.
  634.  
  635.     len( TYPED-VAR )
  636.  
  637.         Returns the length, in bytes, of a typed record
  638.         (one created by DIM AS).
  639.  
  640.     val( STRINGEXPR | EXPR )
  641.  
  642.         Value of the expression contained in a STRINGEXPR or
  643.         EXPR.  STRINGEXPR may be a string literal, variable,
  644.         function, or expression.
  645.         
  646.         For example, VAL("1 + sqr(4)") yields 3.
  647.  
  648.     asc( STRINGEXPR )
  649.  
  650.         Returns the ascii code for the first character of
  651.         STRINGEXPR.  A null string returns zero.
  652.  
  653.     instr(a$, b$ { , VAL } )
  654.  
  655.         Returns the position of the substring b$ in the
  656.         string a$ or returns a zero if b$ is not a substring.
  657.         VAL is an optional starting position in a$
  658.  
  659.     ubound( VAR [, EXPR ] )
  660.     
  661.         If VAR is a dimensioned array, returns the maximum
  662.         legal subscript of the first dimension of that array,
  663.         else returns 0.  Use EXPR to return other dimensions.
  664.  
  665.     isarray( VAR )
  666.     
  667.         If VAR is a dimensioned array, returns the number
  668.         of dimensions, otherwise returns 0.
  669.         
  670.     fgetbyte( FILENUM )
  671.  
  672.         Reads one byte from the open file specified by FILENUM
  673.         and returns an unsigned numeric value [0..255].
  674.  
  675.     eof(FILENUM)
  676.  
  677.         Returns true if the the last INPUT statement, INPUT$
  678.         or FGETBYTE function call which referenced the text
  679.         file specified by FILENUM tried to read past the end
  680.         of file. (Note that reading the last line of a file
  681.         will not read past the eof mark.  A subsequent read is
  682.         needed to set the EOF flag to true.  Reading past the
  683.         end-of-file will not report an error.)
  684.  
  685.     pop
  686.  
  687.         POP function (see also POP statement). Pops one variable
  688.         value off the stack and returns that value (string or
  689.         numeric).
  690.         
  691.         (POP can be used as either a statement (with a
  692.         parameter) or a function (no parameter). Note that the
  693.         POP function, unlike the POP statement, does not
  694.         restore the value of the variable pushed, but only
  695.         returns the pushed value.  This use of the POP
  696.         statement is different from the Applesoft usage.)
  697.  
  698.     peek( ADDR { , SIZE_VAL } )
  699.  
  700.         Returns the value of the byte in memory at address ADDR.
  701.         If SIZE_VAL is 2 or 4, returns the value of the 16-bit
  702.         or 32-bit word respectively (if correctly aligned).
  703.         If SIZE_VAL is 8, returns the value of the numeric
  704.         variable located at ADDR.  (peek(varptr(x),8) == x)
  705.  
  706.     varptr( VAR | STRINGVAR )
  707.     
  708.         Returns the memory address of a variable.
  709.     
  710.     erl
  711.  
  712.         Returns the line number of the last error.  Zero if the
  713.         error was in immediate mode.  The variable errorstatus$
  714.         gives the error type.
  715.  
  716.     timer
  717.  
  718.         Returns a numeric value of elapsed of seconds from the
  719.         computers internal clock.
  720.  
  721.     
  722.     STRING FUNCTIONS
  723.     
  724.     x$ + y$
  725.  
  726.         String concatenation.
  727.     
  728.         String concatenation (and the MID$, LEN and INSTR
  729.         functions) can handle strings of up to 32766 characters
  730.         in length (if the memory available to the program
  731.         permits).
  732.  
  733.     chr$(VAL)
  734.  
  735.         Returns the ascii character corresponding to the value
  736.         of VAL.
  737.  
  738.     str$( VAL { , EXPR } )
  739.  
  740.         Returns a string representation corresponding to VAL.
  741.         If EXPR is present then the string is padded to that
  742.         length.
  743.  
  744.     format$( VAL , STREXPR )
  745.  
  746.         Returns the string representation of VAL formatted
  747.         according to the format string STREXPR. The format
  748.         string STREXPR uses the same formatting syntax as the
  749.         PRINT USING statement.
  750.         
  751.     inkey$
  752.  
  753.         Return one character from the keyboard if input is
  754.         available. Returns a zero length string { "" } if no
  755.         keyboard input is available.  Non-blocking.  Can be
  756.         used for keyboard polling.
  757.  
  758.     input$( EXPR { , FILENUM } )
  759.  
  760.         Returns EXPR characters from file FILENUM. If f is not
  761.         present then get input from the console keyboard.
  762.  
  763.     mid$( a$, i { , j } )
  764.  
  765.         Returns a substring of a$ starting at the i'th
  766.         positions and j characters in length. If the second
  767.         parameter is not specified then the substring is
  768.         taken from the start position to the end of a$.
  769.  
  770.     right$(a$, EXPR )
  771.  
  772.         Returns the right EXPR characters of a$.
  773.  
  774.     left$(a$, EXPR )
  775.  
  776.         Returns the left EXPR characters of a$.
  777.  
  778.     field$( STRINGVAL, VAL { , STRINGVAL } )
  779.  
  780.         Returns the N-th field of the first string.  If the
  781.         optional string is present then use the first character
  782.         of that string as the field separator.  The default
  783.         separator is a space.  Similar to UNIX 'awk' fields.
  784.         
  785.         e.g.  field$("1 22 333 4", 3)  returns  "333"
  786.         
  787.         If VAL is -1 then returns a string with a length
  788.         equal to the number of seperators in the first string.
  789.  
  790.     hex$( VAL { , EXPR } )
  791.     bin$( VAL { , EXPR } )
  792.  
  793.         Returns the hexadecimal or binary string representation
  794.         corresponding to VAL.  If EXPR is present then the
  795.         string is padded with zeros to make it that length.
  796.  
  797.     lcase$( STRINGVAL )
  798.  
  799.         Returns STRINGVAL in all lower case characters.
  800.  
  801.     errorstatus$
  802.  
  803.         Returns the error message for the last error.
  804.  
  805.  
  806.     OPERATORS
  807.  
  808.     The following math operators  are available:
  809.  
  810.         ^    exponentiation
  811.         *    multiplication
  812.         /    division
  813.         mod    remainder
  814.         +    addition
  815.         -    subtraction
  816.  
  817.     logical operators: (any non-zero value is true)
  818.  
  819.             not    logical not
  820.  
  821.     bitwise operators:
  822.  
  823.             and    bitwise and
  824.             or    bitwise or
  825.             xor    bitwise exclusive-or
  826.  
  827.     comparison operators:
  828.  
  829.             <=    less than or equal
  830.             <>    not equal to
  831.             >=    greater than or equal
  832.             =    equal
  833.             >    greater than
  834.             <    less than
  835.  
  836.     x$=y$, x$<y$, x$>y$, x$<=y$, x$>=y$, x$<>y$
  837.  
  838.         String comparisons; result is 1 if true, 0 if false.
  839.         
  840.     Operator precedence (highest to lowest):
  841.  
  842.         ( )
  843.         -{unary_minus}  functions
  844.         ^
  845.         * / mod
  846.         + -
  847.         = < > <= >= <>
  848.         not
  849.         and
  850.         or xor
  851.  
  852.     
  853.     UNIX functions:
  854.  
  855.     sys( STRINGVAL )
  856.  
  857.         UNIX system call.  The string parameter is given to
  858.         the shell as a command.  Returns exit status.
  859.  
  860.     getenv$( STRINGVAL )
  861.          
  862.         Returns value for environment name STRINGVAL.
  863.               
  864.     argv$
  865.         Returns the UNIX shell command line arguments.
  866.  
  867.  
  868.     Macintosh commands:
  869.  
  870.     *** NOTE ***
  871.     
  872.         Many MacOS specific functions and commands are only
  873.         documented in the Chipmunk Basic quick reference file.
  874.  
  875.     gotoxy VAL, VAL
  876.  
  877.         Set the horizontal and vertical location of the
  878.         text output cursor.  (0,0) is the upper left corner.
  879.  
  880.     moveto VAL, VAL
  881.  
  882.         Sets the (x,y) location of the graphics pen.
  883.  
  884.     lineto VAL, VAL
  885.  
  886.         Draws a line from the current pen location to location
  887.         (x,y) in the graphics window.
  888.  
  889.     window x, y, char_cols, char_lines
  890.  
  891.         Change the text console window position and size.
  892.  
  893.     morse STRINGVAL { , VAL, VAL, VAL, VAL }
  894.  
  895.         Plays morse code through the speaker.
  896.         The parameters are: dot-speed-wpm, volume{0..100},
  897.         word-speed-wpm, frequency{in Hz or cps}
  898.  
  899.     sound VAL, VAL, VAL 
  900.  
  901.         The parameters are:
  902.         frequency{in Hz}, seconds_duration, volume{0..100}
  903.     
  904.     say STRINGVAL
  905.  
  906.         Speaks STRINGVAL if the Speech Manager Extension is
  907.         resident.  Try "say a$,200,46,1" for faster speech.
  908.  
  909.     open "SFGetFile" for input  as #FNUM
  910.     open "SFPutFile" for output as #FNUM
  911.  
  912.         Puts up a standard file dialog for the file name.
  913.  
  914.     files { STRINGVAL }
  915.     
  916.         Displays a listing of files in the named or current
  917.         directory.
  918.     
  919.     Macintosh functions:
  920.     
  921.     fre
  922.         Returns the amount of memory left for program use. 
  923.     
  924.     date$
  925.         Returns a string corresponding to the current date.
  926.  
  927.     time$
  928.         Returns a string corresponding to the current time.
  929.  
  930.     pos(VAL)
  931.  
  932.         Returns the horizontal position of the text cursor.
  933.         If VAL is negative returns the vertical position.
  934.     
  935.     errorstatus$
  936.     
  937.         Also returns the full path name of the program and
  938.         files opened by SFGetFile and SFPutFile. (Only under System 7
  939.         and also only if the name fits in a string variable)
  940.     
  941.     
  942.     Macintosh menu items:
  943.  
  944.     Open or <cmd>O     will put up a dialog to allow selection
  945.             of a program file to load.  Basic Program
  946.             file names must end with a ".bas" suffix.
  947.  
  948.     Copy        will allow copying picts from the graphics
  949.             window.
  950.     
  951.     <cmd>.         Command-period will stop program execution.
  952.  
  953.     Print        Print graphics window if it's the frontmost
  954.             window. Only the graphics window can be printed.
  955.  
  956.  
  957.     RESERVED WORDS AND SYMBOLS
  958.  
  959.     + - * / ^ mod  and or xor not  > < >= <= <> = ()
  960.     sqr log exp sin cos tan atn  pi
  961.     abs sgn int rnd peek val asc len
  962.     mid$ right$ left$ str$ chr$  lcase$ ucase$
  963.     goto  if then else endif  gosub return
  964.     for to step next  while wend  select case
  965.     rem  let  dim erase  data read restore   field$
  966.     input print open for output append as close# load save
  967.     random lof loc get put   
  968.     inkey$  input$ eof  files  fgetbyte# fseek# fputbyte
  969.     run stop end exit quit cont  renum  new clear
  970.     date$ time$ timer  sound morse say  doevents
  971.     home cls gotoxy htab vtab pos 
  972.     graphics sprite pset moveto lineto window scrn mouse
  973.     varptr peek poke fre push pop  isarray
  974.     sub call usr  def fn
  975.     type class extends  string integer single double
  976.     asin acos sinh cosh tanh log10 floor true false ubound
  977.     
  978.     eqv imp  static  option degrees radians redim
  979.     msgbox  do loop until break
  980.     method private public local   menu dialog memstat()
  981.     draw play  bload bsave  min max mat
  982.     each  resume  function
  983.     key is each set width swap
  984.     
  985.  
  986.     CONVENTIONS
  987.  
  988.     EXPR        an expression that evaluates to a numeric value.
  989.     STRINGEXPR    a string expression.
  990.     VAR        a numeric variable.
  991.     STRINGVAR    a string variable. Name must end with a "$".
  992.     INTEGERVAR    a 16-bit variable. Name must end with a "%".
  993.     
  994.     All program lines must begin with a line number.
  995.     Using spaces (indentation) between the line number and
  996.     program statements is legal.  Line numbers can be
  997.     between 1 and 2147483647.  Programs lines must be no
  998.     longer than 254 characters in length.
  999.     
  1000.     Subroutine names starting with "fn" are reserved for the
  1001.     (obsolete) def fn functions.
  1002.     
  1003.     Hexadecimal numbers can be entered by preceding them with
  1004.     a "0x" as in 0x02ae, or by "&h" as in &h0172.
  1005.     
  1006.     Multiple statements may be given on one line, separated by
  1007.     colons:
  1008.  
  1009.         10 INPUT X : PRINT X : STOP
  1010.  
  1011.  
  1012.     DIAGNOSTICS
  1013.  
  1014.     Some errors can be caught by the user program using the
  1015.     "on error goto" command. If no error trapping routine has been
  1016.     supplied then program execution is terminated and a message is
  1017.     printed with the corresponding line number.
  1018.  
  1019.     Graphics (MacOS) may require that the preferred memory
  1020.     requirements be increased using the Finder "Get Info" dialog
  1021.     box.
  1022.  
  1023.  
  1024.     CHANGES
  1025.     
  1026.      v3.5.3    - allow integer (i%) variables as for/next loop indices
  1027.      v3.4.7    - lower precedence of NOT operator
  1028.          - disabled ON GOTO range checking
  1029.      v3.4.6    - added MAT matrix statements
  1030.      v3.4.0    - OPEN ELSE added
  1031.      v3.3.4    - changed integer conversion to rounding
  1032.          - changed sub return values to: sub_name = x
  1033.          - added reserved words for: true false
  1034.      v3.3.3  - added acos, tanh, log10
  1035.      v3.2.8    - added class definitions
  1036.      
  1037.      Many others ...
  1038.  
  1039.     BUGS
  1040.  
  1041.     Many.  Perhaps competitive with Central American rain forests.
  1042.     
  1043.     FOR/NEXT loops with integer indices require a variable in the
  1044.     NEXT statement. Integer arrays can only have a dimension of
  1045.     one and will only work in assignment (LET) statements.  All
  1046.     arithmetic on integer variables is done using floating point
  1047.     arithmetic.  DIM AS DOUBLE and DIM AS INTEGER statements are
  1048.     ignored.
  1049.     
  1050.     Many string functions (except +, MID$, LEN and INSTR) silently
  1051.     truncate their results to 254 characters (e.g. without
  1052.     warning). All string function may silently truncate strings
  1053.     longer than 32766 characters. Any operation on strings longer
  1054.     than 254 characters will cause the program to run slower.
  1055.     
  1056.     Comments starting with ' sometimes can't be used after
  1057.     statements that can end with a string parameter. ( : '
  1058.     should always work.)
  1059.     
  1060.     Any variables used as a CLASS, or TYPE, globally overide all
  1061.     local variables of the same names.  Local TYPE'd variables
  1062.     must be declared globally as TYPE'd variables.  Named SUBroutines
  1063.     are slower than GOSUBs. The combined length of a SUBroutine name
  1064.     and any local variables declared STATIC must be less than 29
  1065.     characters.
  1066.     
  1067.     Can't CONTinue from an error inside a named SUB subroutine.
  1068.     
  1069.     The PRINT USING format string doesn't recognize comma's,
  1070.     underscores and many other common format characters.
  1071.     
  1072.     Macintosh screen editing will only recognise the last line
  1073.     modified before a RETURN or ENTER key.  The EDIT command and
  1074.     Mac screen editing are incompatible.
  1075.  
  1076.     There are many undocumented graphics and sprite commands
  1077.     and keywords in the Macintosh port.  See the accompanying
  1078.     README and Chipmunk Basic quick-reference file.
  1079.     
  1080.  
  1081.     DISCLAIMER
  1082.  
  1083.     There is no warranty that this document is accurate.
  1084.  
  1085.     AUTHORS
  1086.     
  1087.     David Gillespie wrote basic.p 1.0 and the p2c lib.
  1088.     Ron Nicholson (rhn@nicholson.com) added file i/o, graphics
  1089.     and did the Unix, Macintosh and PowerMac port. (1990-1997Nov)
  1090.  
  1091.     Portions of this document are Copyright (C) 1989 Dave Gillespie.
  1092.     Copyright (C)1994,1998 Ronald H. Nicholson, Jr. (rhn@nicholson.com),
  1093.     All rights reserved.
  1094.     "Applesoft" is a trademark of Apple Computer, Inc., etc.
  1095.  
  1096. </PRE>
  1097. </BODY>
  1098. </HTML>
  1099.